#ifndef QUOTE_LEVEL_K_INDEX_H
#define QUOTE_LEVEL_K_INDEX_H

#include "QuoteLvData.h"

//lisz add 20110916 start
#define K_INDEX_L2XX_N1  60
#define K_INDEX_L2XX_N2  5
#define K_INDEX_L2XX_N3  10
#define K_INDEX_L2BBD_N1 3
#define K_INDEX_L2BBD_N2 5
#define K_INDEX_L2BBD_N3 10
//lisz add 20110916 end

///KDJ结构
typedef struct QUOTELV_K_KDJ_tag
{
    ///KDJ指标K的值
	double		K[KLIN_MAX_NUM];
    ///KDJ指标D的值
	double		D[KLIN_MAX_NUM];
    ///KDJ指标J的值
	double		J[KLIN_MAX_NUM];
}QUOTELV_K_KDJ;

///DMA结构
typedef struct QUOTELV_K_DMA_tag
{
    ///DMA指标DDD的值
	double		DDD[KLIN_MAX_NUM];
    ///DMA指标AMA的值
	double		AMA[KLIN_MAX_NUM];
}QUOTELV_K_DMA;

///BOOL结构
typedef struct QUOTELV_K_BOLL_tag
{
    ///上轨线
	double		MID[KLIN_MAX_NUM];
    ///中轨线
	double		UPPER[KLIN_MAX_NUM];
    ///下轨线
	double		LOWER[KLIN_MAX_NUM];
}QUOTELV_K_BOLL;

///BOOL_MAIN主图结构
typedef struct QUOTELV_K_BOLL_MAIN_tag
{
	///上轨线
	double		MID[KLIN_MAX_NUM];
	///中轨线
	double		UPPER[KLIN_MAX_NUM];
	///下轨线
	double		LOWER[KLIN_MAX_NUM];
}QUOTELV_K_BOLL_MAIN;

///RSI结构
typedef struct QUOTELV_K_RSI_tag
{	
    ///RSI1
	double		RSI1[KLIN_MAX_NUM];	
	///RSI2
	double		RSI2[KLIN_MAX_NUM];		
    ///RSI3
	double		RSI3[KLIN_MAX_NUM];		
}QUOTELV_K_RSI;

///MACD
typedef struct QUOTELV_K_MACD_tag
{		
    ///DIF
	double		DIF[KLIN_MAX_NUM];			
    ///DEA
	double		DEA[KLIN_MAX_NUM];		
    ///MACD
	double		MACD[KLIN_MAX_NUM];	

    ///短EMA
	double		shortEMA[KLIN_MAX_NUM];
    ///长EMA
	double		longEMA[KLIN_MAX_NUM];
}QUOTELV_K_MACD;

///报价均线
typedef struct QUOTELV_K_PAVG_tag
{		
    ///周期5均价
	double		M5[KLIN_MAX_NUM];
    ///周期10均价
	double		M10[KLIN_MAX_NUM];		
    ///周期20均价
	double		M20[KLIN_MAX_NUM];	
    ///周期60均价
	double		M60[KLIN_MAX_NUM];
}QUOTELV_K_PAVG;

///DMI
typedef struct QUOTELV_K_DMI_tag
{		
	double		PDI[KLIN_MAX_NUM];			
	double		MDI[KLIN_MAX_NUM];		
	double		ADX[KLIN_MAX_NUM];	
	double		ADXR[KLIN_MAX_NUM];
}QUOTELV_K_DMI;

///成交量均线
typedef struct QUOTELV_K_VAVG_tag
{		
    ///周期5均量
	double		M5[KLIN_MAX_NUM];	
    ///周期10均量
	double		M10[KLIN_MAX_NUM];		
}QUOTELV_K_VAVG;

///威廉指标
typedef struct QUOTELV_K_WR_tag
{		
	double		WR1[KLIN_MAX_NUM];			
	double		WR2[KLIN_MAX_NUM];		
}QUOTELV_K_WR;

///商品路径指标
typedef struct QUOTELV_K_CCI_tag
{		
	double		CCI[KLIN_MAX_NUM];			
}QUOTELV_K_CCI;

///BIAS乖离率
typedef struct QUOTELV_K_BIAS_tag
{		
	double		BIAS1[KLIN_MAX_NUM];
	double		BIAS2[KLIN_MAX_NUM];
	double		BIAS3[KLIN_MAX_NUM];
}QUOTELV_K_BIAS;

///ARBR人气意愿指标
typedef struct QUOTELV_K_ARBR_tag
{		
	double		AR[KLIN_MAX_NUM];
	double		BR[KLIN_MAX_NUM];
}QUOTELV_K_ARBR;

///PSY 心理线
typedef struct QUOTELV_K_PSY_tag
{		
	double		PSY[KLIN_MAX_NUM];
}QUOTELV_K_PSY;


//lisz add 20110915 start

///Leve2 ddx
typedef struct QUOTELV_K_LEVE_DDX_tag
{
  double  ddx[KLIN_MAX_NUM];
  double  ddx1[KLIN_MAX_NUM];
  double  ddx2[KLIN_MAX_NUM];
  double  ddx3[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_DDX;

///Leve2 ddy
typedef struct QUOTELV_K_LEVE_DDY_tag
{
  double  ddy[KLIN_MAX_NUM];
  double  ddy1[KLIN_MAX_NUM];
  double  ddy2[KLIN_MAX_NUM];
  double  ddy3[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_DDY;

///Leve2 ddz
typedef struct QUOTELV_K_LEVE_DDZ_tag
{
  double  ddz[KLIN_MAX_NUM];
  double  ddz1[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_DDZ;

///Leve2 bbd retai hold
typedef struct QUOTELV_K_LEVE_BBD_RETAI_tag
{
  ///持仓
  double  shareholdingRatio[KLIN_MAX_NUM];
  ///当日波动(当日增减)
  double  currentFluctuation[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_BBD_RETAI;

///Leve2 bbd main hold
typedef struct QUOTELV_K_LEVE_BBD_MAIN_tag
{
  ///持仓
  double  shareholdingRatio[KLIN_MAX_NUM];
  ///当日波动(当日增减)
  double  currentFluctuation[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_BBD_MAIN;

///Leve2 bbd
typedef struct QUOTELV_K_LEVE_BBD_tag
{
  ///主力净额
  long64  bbd[KLIN_MAX_NUM];
  ///周期1和
  long64  sum1[KLIN_MAX_NUM];
  ///周期2和
  long64  sum2[KLIN_MAX_NUM];
  ///周期3和
  long64  sum3[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_BBD;

typedef struct QUOTELV_K_LEVE_AVG_VOL_SUM_tag
{
  ///均量
  double  avgVol[KLIN_MAX_NUM];
  ///均额
  double  avgSum[KLIN_MAX_NUM];
}QUOTELV_K_LEVE_AVG_VOL_SUM;

//lisz add 20110915 end


///指标结构
typedef struct QUOTELV_K_INDEX_tag
{
///KDJ
	QUOTELV_K_KDJ		KDJ;
    ///KDJ周期
	int					KDJ_N;
    ///KDJ M1日平均
	int					KDJ_M1;
    ///KDJ M2日平均
	int					KDJ_M2;

///DMA
	QUOTELV_K_DMA		DMA;
	int					DMA_SHORT;
	int					DMA_LONG;
	int					DMA_M;

//BOLL
	QUOTELV_K_BOLL		BOLL;
	int					BOLL_N;
	int					BOLL_P;
	
//BOLL_MAIN(主图)
	QUOTELV_K_BOLL_MAIN		BOLL_MAIN;
	int					BOLL_MAIN_N;
	int					BOLL_MAIN_P;

//RSI
	QUOTELV_K_RSI		RSI;
	int					RSI_N1;
	int					RSI_N2;
	int					RSI_N3;

//MACD
	QUOTELV_K_MACD		MACD;
    ///MACD 短期
	int					MACD_SHORT;
    ///MACD 长期
	int					MACD_LONG;
    ///MACD 天数
	int					MACD_MID;

//AVG
	QUOTELV_K_PAVG		PAVG;
    ///PAVG 周期1
	int					PAVG_N1;
    ///PAVG 周期2
	int					PAVG_N2;
    ///PAVG 周期3
	int					PAVG_N3;
    ///PAVG 周期4
	int					PAVG_N4;

//DMI
	QUOTELV_K_DMI		DMI;
	int					DMI_N;
	int					DMI_MM;

//VAVG
	QUOTELV_K_VAVG		VAVG;
    ///VAVG 周期1
	int					VAVG_N1;
    ///VAVG 周期2
	int					VAVG_N2;
	
//WR
	QUOTELV_K_WR		WR;
    ///WR 周期1
	int					WR_N;
    ///WR 周期2
	int					WR_N1;
	
//CCI
	QUOTELV_K_CCI		CCI;
    //CCI 周期1
	int					CCI_N;
	
//BIAS
	QUOTELV_K_BIAS		BIAS;
    ///BIAS 周期1
	int					BIAS_L1;
    ///BIAS 周期1
	int					BIAS_L2;
    ///BIAS 周期1
	int					BIAS_L3;
	
//ARBR
	QUOTELV_K_ARBR		ARBR;
    ///ARBR 周期1
	int					ARBR_N;
	
//ARBR
	QUOTELV_K_PSY		PSY;
    ///PSY 周期1
	int					PSY_N;

  ///DDX
  QUOTELV_K_LEVE_DDX DDX;
  
  ///DDY
  QUOTELV_K_LEVE_DDY DDY;
  
  ///DDZ
  QUOTELV_K_LEVE_DDZ DDZ;
  
  ///BBD 散户
  QUOTELV_K_LEVE_BBD_RETAI BBDRetai;
  ///BBD 主力
  QUOTELV_K_LEVE_BBD_MAIN  BBDMain;
  ///BBD 净额
  QUOTELV_K_LEVE_BBD  BBD;
  ///均量，均额
  QUOTELV_K_LEVE_AVG_VOL_SUM AVG_VOL_SUM;
  
}QUOTELV_K_INDEX;


/**K线指标操作结构初始化
*
*  @param 无
*
*  @return QUOTELV_OPER*	K线指标指针
*
*		
*/
QUOTELV_K_INDEX* QuoteLvKIndex_New();


/**计算KDJ指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*		aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcKDJ(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算DMA指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*		
*/
void QuoteLvKIndex_calcDMA(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算BOLL指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcBOLL(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);
void QuoteLvKIndex_calcMainBOLL(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算RSI指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcRSI(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算MACD指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcMACD(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);


/**计算报价均线值
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*		
*/
void QuoteLvKIndex_calcPriceAVG(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算成交量均线值
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcVolAVG(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算DMI指标
*
*  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
*  @param QUOTELV_K_RES*			aRes		k线应答结构
*
*  @return -
*
*		
*/
void QuoteLvKIndex_calcDMI(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算WR指标
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcWR(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算CCI指标
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcCCI(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算BIAS指标
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcBIAS(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算ARBR人气意愿指标
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcARBR(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算PSY心理线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcPSY(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

//lisz add 20110916 start
/**计算DDX线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcDDX(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算DDY线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcDDY(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算DDZ线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcDDZ(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算BBD Retai线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcBBDRetai(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算BBD Retai线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcBBDMain(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算BBD 净额线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcBBD(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);

/**计算均量，均额线
 *
 *  @param QUOTELV_K_INDEX*		aKIndex		操作结构指针
 *  @param QUOTELV_K_RES*			aRes		k线应答结构
 *
 *  @return -
 *
 *		
 */
void QuoteLvKIndex_calcAvgVolSum(QUOTELV_K_INDEX* aKIndex, QUOTELV_K_RES* aRes);
//lisz add 20110916 end

#endif